/*
	YoghurtGum - 2D Game Engine

	Copyright 2009-2011 Quinten Lansu
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may not 
	use this file except in compliance with the License. You may obtain a copy 
	of the License at 
		
		http://www.apache.org/licenses/LICENSE-2.0 
		
	Unless required by applicable law or agreed to in writing, software 
	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
	License for the specific language governing permissions and limitations 
	under the License. 
*/

#ifndef _YGRENDERMETHOD_H_
#define _YGRENDERMETHOD_H_

#include "YGSettings.h"
#include "YGSources.h"
#include "YGColor.h"

namespace YoghurtGum
{

	class Sprite;
	class SpriteEx;
	class Background;
	class Surface;
	class Viewport;
	class Window;

	typedef uint32 hImage;
	typedef uint32 hSprite;
	typedef uint32 hBackground;
	typedef uint32 hViewport;

	/*template<class Type>
	struct YG_EXPORT DataBox
	{ 
		char name[128];
		Type* data;
		DataBox<Type>* next;
	};*/

	struct DataSprite
	{
		char file[256];
		char name[128];
		Color key;
		unsigned int properties;
		int sizex, sizey;
	};

	class YG_EXPORT RenderMethod
	{

	public:

		virtual ~RenderMethod();

		virtual bool Init() { return true; }
		virtual void Resize(int a_Width, int a_Height) = 0;
		virtual void CleanUp() { }

		void Install();

		void SetDeviceDimensions(int32 a_Width, int32 a_Height);
		bool SetProperty(const char* a_Name, void* a_Data);

		virtual void SetClearColor(Color a_Color) { }
		virtual void SetFullScreen() { }

		virtual char* GetName() = 0;

		virtual bool Clear() { return true; }
		virtual bool PreRender() { return true; }
		virtual bool PostRender() { return true; }

		virtual Surface* GetRenderTarget() = 0;

		virtual bool LoadImage(const char* a_File, const char* a_Name, Color a_AlphaKey = Color::CNONE) = 0;

		virtual Sprite* CreateSprite(const char* a_Name) = 0;
		virtual SpriteEx* CreateSpriteEx(const char* a_Name, uint32 a_Flags = YG_SPRITEEX_DEFAULT) = 0;
		virtual Background* CreateBackground(const char* a_Name, uint32 a_Flags = YG_BACKGROUND_DEFAULT) = 0;
		virtual Surface* CreateSurface(int a_Width, int a_Height, uint32 a_Flags = YG_SURFACE_DEFAULT) = 0;

		virtual uint32 CreateViewport(uint32 a_Width, uint32 a_Height, uint32 a_Type = YG_VIEWPORT_DEFAULT) = 0;
		virtual Viewport* GetViewport(uint32 a_ID) = 0;
		virtual bool SetViewport(uint32 a_ID) = 0;

	protected:

		RenderMethod();

		char                  m_PluginName[256];

#if (YG_OS_TYPE == YG_OS_TYPE_WINDOWSMOBILE)

		HWND                  m_WindowHandle;

#endif

		int32                 m_DeviceWidth, m_DeviceHeight;

		DataSprite            m_SpriteTypes[256];
		uint32                m_SpriteTypesTotal;

		Sprite*               m_SpriteList[256];
		uint32                m_SpriteTotal;

		Background*           m_Backgrounds[256];
		uint32                m_BackgroundsFilled;

	}; // class RenderMethod

}; // namespace YoghurtGum

#endif
